#include<iostream>//双向循环链表
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
class Bid_cir_linked_list
{
    public:
        struct node
        {
            int value;
            node *front,*next;
        }*start,*end;
        Bid_cir_linked_list();
        void li_insert(int x);
        void li_delete(int id);
        void li_print();
};
Bid_cir_linked_list::Bid_cir_linked_list()
{
    start=end=NULL;
}
void Bid_cir_linked_list::li_insert(int x)
{
    node *new_node;
    if(start==NULL)
    {
        new_node=(node *)malloc(sizeof(node));
        new_node->value=x;
        new_node->front=new_node->next=NULL;
        end=start=new_node;
    }
    else{
        new_node=(node *)malloc(sizeof(node));
        new_node->value=x;
        end->next=new_node;
        new_node->front=end;
        new_node->next=start;
        start->front=new_node;
        end=new_node;
    }
}
void Bid_cir_linked_list::li_delete(int id)
{
    int cnt=1;
    node *p=start;
    while(p!=end)
    {
        if(cnt==id)
        {
            if(p!=start&&p!=end)
            {
                node *fr=p->front;
                node *ne=p->next;
                fr->next=ne;
                ne->front=fr;
                free(p);
                break;
            }
            else if(p==start)
            {
                node *fr=p->front;
                node *ne=p->next;
                fr->next=ne;
                ne->front=fr;
                start=ne;
                free(p);
                break;
            }
        }
        p=p->next;
        cnt++;
    }
    if(p==end)
    {
        node *fr=p->front;
        node *ne=p->next;
        fr->next=ne;
        ne->front=fr;
        end=fr;
        free(p);
    }
}
void Bid_cir_linked_list::li_print()
{
    node *p=start;
    while(p!=end)
    {
        cout<<p->value<<' ';
        p=p->next;
    }
    cout<<end->value<<endl;
}
int main()
{
    int n,x;
    Bid_cir_linked_list L;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        L.li_insert(x);
    }
    cout<<"delete id:"<<endl;
    int de_id;
    cin>>de_id;
    L.li_delete(de_id);
    L.li_print();
    return 0;
}